package com.taxt.ui.activity;

import android.net.Uri;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.hjq.http.EasyHttp;
import com.hjq.http.listener.HttpCallback;
import com.hjq.widget.layout.SettingBar;
import com.taxt.R;
import com.taxt.app.AppActivity;
import com.taxt.http.api.JobDataApi;
import com.taxt.http.model.HttpData;
import com.taxt.other.SpUtils;
import com.taxt.ui.adapter.JobDataAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import okhttp3.Call;


/**
 *    author : wq

 *    time   : 2019/04/20
 *    desc   : 任职受雇信息
 */
public final class PersonalJobDataActivity extends AppActivity {
    private RecyclerView mJobRcv;
    JobDataAdapter jobDataAdapter;
    private List<JobDataApi.Bean>list=new ArrayList<>();
    @Override
    protected int getLayoutId() {
        return R.layout.personal_job_data_activity;
    }

    @Override
    protected void initView() {
        mJobRcv=findViewById(R.id.job_rcv);
        jobDataAdapter=new JobDataAdapter(this,list);
        mJobRcv.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false));
        mJobRcv.setAdapter(jobDataAdapter);
    }

    @Override
    protected void initData() {
        getJobData();
    }



    public void getJobData(){
        HashMap<String,String>map=new HashMap<>();
        map.put("personId", SpUtils.decodeString("personId"));
        EasyHttp.post(this)
                .json(map)
                .api(new JobDataApi()
                )
                .request(new HttpCallback<HttpData<List<JobDataApi.Bean>>>(this) {

                    @Override
                    public void onStart(Call call) {

                    }

                    @Override
                    public void onEnd(Call call) {
                    }

                    @Override
                    public void onSucceed(HttpData<List<JobDataApi.Bean>> data) {
                        if (data.getData() != null) {
                            list.clear();
                            list.addAll(data.getData());
                            jobDataAdapter.setData(list);
                        }
                    }

                    @Override
                    public void onFail(Exception e) {
                        super.onFail(e);
                    }
                });
    }

}